package com.woman.beautylive.presentation.ui.main.find.adapter;

import android.content.Context;
import android.media.Image;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.woman.beautylive.R;
import com.woman.beautylive.data.bean.HotAreaBean;
import com.woman.beautylive.presentation.ui.main.BlankFragment;

import java.util.HashMap;
import java.util.List;

public class PengYouQuanAdapter extends RecyclerView.Adapter<PengYouQuanAdapter.Holder>{
    private int layoutbgpreead,layoutbgup;
    private Context context;
    private List<HotAreaBean> list;
    private LayoutInflater mInflater;
    private HashMap<Integer,Holder> itemintlist;
    private View.OnClickListener commentOnclickListener;

    public PengYouQuanAdapter(Context context, List<HotAreaBean> placelist,View.OnClickListener commentOnclickListener) {
        this.context = context;
        this.list = placelist;
        mInflater = LayoutInflater.from(context);
        itemintlist=new HashMap<Integer,Holder>();
        this.commentOnclickListener=commentOnclickListener;
    }

    public Holder viewHolder;

    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
//        找到我们的item布局
        View view = mInflater.inflate(R.layout.item_circle_friends,parent,false);
//        实例化一个Myviewholder对象 ,并传入我们的item布局
        viewHolder  = new Holder(view);
        return viewHolder;
    }




    @Override
    public void onBindViewHolder(final Holder holder, final int position) {
        itemintlist.put(position,holder);
//        holder.mTitile.setText(list.get(position).getCity());
//        holder.mNumber.setText(list.get(position).getAnchorcnt() + " 在看");
        viewHolder.item_friend_commentimg.setOnClickListener(commentOnclickListener);
        viewHolder.item_friend_commentimg.setTag(R.id.tag_1,position);
    }

    @Override
    public int getItemCount() {
        if (list==null){
            return 0;
        }
        return list.size();
    }

    public void setDataList(List<HotAreaBean> placelist) {
        this.list = placelist;
        notifyDataSetChanged();
    }

    //    ========================1=========================点击监听 需要我们自己来写，但是依然需要用到系统的点击回调




    //    内部类holder
    public class Holder extends RecyclerView.ViewHolder {

//        private TextView mTitile, mNumber;
        ImageView my_me_photo,item_goodfriends_tag1,item_goodfriends_tag2,item_friend_commentimg;
        TextView item_billboard_name,item_billboard_contant,item_friend_time;
        private ImageView mImg;
        public Holder(View itemView) {
            super(itemView);
//            mTitile = (TextView) itemView.findViewById(R.id.index_recy_title);
//            mNumber = (TextView) itemView.findViewById(R.id.index_recy_number);
//            mImg = (ImageView) itemView.findViewById(R.id.index_recy_img);
             item_billboard_name=(TextView)itemView.findViewById(R.id.item_billboard_name);
             item_billboard_contant=(TextView)itemView.findViewById(R.id.item_billboard_contant);
             item_friend_time=(TextView)itemView.findViewById(R.id.item_friend_time);
             my_me_photo=(ImageView)itemView.findViewById(R.id.my_me_photo);
             item_goodfriends_tag1=(ImageView)itemView.findViewById(R.id.item_goodfriends_tag1);
             item_goodfriends_tag2=(ImageView)itemView.findViewById(R.id.item_goodfriends_tag2);
             item_friend_commentimg=(ImageView)itemView.findViewById(R.id.item_friend_commentimg);
      }
    }
}